package example.app;

import java.util.List;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class CRssListAdapter extends ArrayAdapter<CItem> {
	private LayoutInflater mInflater;
	private TextView mTitle;
	private TextView mDescr;
	
	/**
	 * 
	 * @param aContext
	 * @param aObjects
	 */
	public CRssListAdapter(Context aContext, int aResourceId, List<CItem> aObjects) {
		super(aContext, aResourceId, aObjects);
		mInflater = (LayoutInflater)aContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	
	/**
	 * 
	 */
	@Override
	public View getView(int aPosition, View aConvertView, ViewGroup aParent) {
		View view = aConvertView;
		
		if(aConvertView == null) {
			view = mInflater.inflate(R.layout.item_row, null);
		}
		
		//
		CItem item = this.getItem(aPosition);
		if(item != null) {
			//
			String title = item.GetTitle().toString();
			mTitle = (TextView)view.findViewById(R.id.item_title);
			mTitle.setText(title);
			mTitle.setTextColor(Color.rgb(150, 220, 255));
			String descr = item.GetDescription().toString();
			mDescr = (TextView)view.findViewById(R.id.item_descr);
			mDescr.setText(descr);
		}
		
		return view;
	}
}
